<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
<script>
let obj = {
    a: 1,
    b: 2,
    c: 3
};
obj[Symbol.iterator] = function(){
    // 迭代协议
    let values = Object.values(obj);
     console.log(values)
    let index = 0;
    //console.log(values);
    return {
        next(){
            if(index >= values.length){
                return {
                    done: true
                }
            } else {
                return {
                    done: false,
                    value:  values[index++]
                }
            }
        }
    }
};
let values = obj[Symbol.iterator]();
console.log(values.next());
console.log(values.next());
console.log(values.next());
console.log(values.next());
// for(let val of obj){
//     console.log(val);
// }
</script>    
</body>
</html>